<%--
  Created by IntelliJ IDEA.
  User: 92460
  Date: 2020/12/14
  Time: 16:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>获取客户端的cookie信息</title>
</head>
<body>
<%
    String username = null;
    String password = null;
    Cookie[] cookies = request.getCookies();
    for (int i = 0; i <cookies.length; i++) {
        if (cookies[i].getName().equals("username")){
            username = cookies[i].getValue();
            break;
        }
    }
    for (int i = 0; i < cookies.length; i++) {
        if (cookies[i].getName().equals("password")){
            password = cookies[i].getValue();
            break;
        }
    }

    out.print("获取到的用户名为"+username);
    out.print("<br/>");
    out.print("获取到的用户名为"+password);
%>
</body>
</html>
